/**
 * Created by dell on 2018/12/5.
 */
/*
大文件操作（流式操作）
 fs.createReadStream(path[, options])
 fs.createWriteStream(path[, options])
 */
//require 引入的模块
const path = require('path');
const fs = require('fs');

let spath = path.join(__dirname,'网站.zip');
let dpath = path.join('C:\\Users\\dell','网站.zip');

// let readStream = fs.createReadStream(spath);
// let writeStream = fs.createWriteStream(dpath);

// let num = 1;
// //chunk块
// readStream.on('data',(chunk)=>{
//     num++;
//     writeStream.write(chunk);
// });
//
// readStream.on('end',()=>{
//     console.log('文件处理完成'+num);
// });

//pipe的作用直接把输入流和输出流
//输入流：磁盘到内存
//输出流：内存写到磁盘
// readStream.pipe(writeStream);

//---------------------------------
fs.createReadStream(spath).pipe(fs.createReadStream(dpath));